package performance;

/**
 * This class controls the counter for the True/False : Positive/Negative MAtrix 
 * @author Danielondon
 *
 */
public class PerformanceResult {
	
	public static final char POSITIVE = '+';
	public static final char NEGATIVE = '-';
	
	private int truePositives;
	private int falsePositives;
	private int trueNegatives;
	private int falseNegatives;
	
	
	/**
	 * This method resolves which attribute to increase 
	 * @param classification
	 * @param groundTrue
	 */
	public void evaluateResult(char classification, char groundTrue) {
		if (classification == groundTrue){
			if (classification == POSITIVE)
				this.truePositives++;
			else
				this.trueNegatives++;				
		} else {
			if (classification == POSITIVE)
				this.falsePositives++;
			else
				this.falseNegatives++;
		}
	}
	
	/**
	 * Gets the positive accuracy
	 * @return
	 */
	public double getPositiveAccuracy() {
		return ((double)(truePositives)/(double)(truePositives+falsePositives));
	}

	/**
	 * Gets the negative accuracy
	 * @return
	 */
	public double getNegativeAccuracy() {
		return ((double)(trueNegatives)/(double)(trueNegatives+falseNegatives));
	}

	/**
	 * Gets the positive coverage
	 * @return
	 */
	public double getPositiveCoverage() {
		return ((double)(truePositives)/(double)(truePositives+falseNegatives));
	}

	/**
	 * Gets the Negative Coverage
	 * @return
	 */
	public double getNegativeCoverage() {
		return ((double)(trueNegatives)/(double)(trueNegatives+falsePositives));
	}
	
	public double getOverallPerformance(){
		return ((double)truePositives+trueNegatives) / ((double)truePositives+trueNegatives+falsePositives+falseNegatives);
	}
	
	public int getTruePositives() {
		return truePositives;
	}
	public int getFalsePositives() {
		return falsePositives;
	}
	public int getTrueNegatives() {
		return trueNegatives;
	}
	public int getFalseNegatives() {
		return falseNegatives;
	}	
}
